<?php

namespace app\agentapi\model;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
class Sms{
    /**
     * @param string[] $args
     * @return void
     */
    public static function main($phone,$name){
        AlibabaCloud::accessKeyClient('LTAI5t8y1jUjfcR4NdMAXMNB', 'UJLUu7FzVteqlpWT3sN0a37gtUguCZ')
            ->regionId('cn-hangzhou')
            ->asDefaultClient();
        try {
            $result = AlibabaCloud::rpcRequest()
                ->product('Dysmsapi')
                ->version('2017-05-25')
                ->action('SendSms')
                ->method('POST')
                ->options([
                    'query' => [
                        'PhoneNumbers' => $phone,
                        'SignName' => '众拓通',
                        'TemplateCode' => 'SMS_222180139',
                        'TemplateParam' => "{\"code\":\"".$name."\"}",
                    ],
                ])
                ->request();
            return json_decode($result,'true');
        } catch (ClientException $e) {
            return $e->getErrorMessage();
        } catch (ServerException $e) {
            return $e->getErrorMessage();
        }
    }


}

